package com.zzyl.pred.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zzyl.common.annotation.Log;
import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.enums.BusinessType;
import com.zzyl.pred.domain.Pred;
import com.zzyl.pred.service.IPredService;
import com.zzyl.common.utils.poi.ExcelUtil;
import com.zzyl.common.core.page.TableDataInfo;

/**
 * 水质预测结果数据Controller
 * 
 * @author ruoyi
 * @date 2025-06-24
 */
@RestController
@RequestMapping("/pred/pred")
public class PredController extends BaseController
{
    @Autowired
    private IPredService predService;

    /**
     * 查询水质预测结果数据列表
     */
    @PreAuthorize("@ss.hasPermi('pred:pred:list')")
    @GetMapping("/list")
    public TableDataInfo list(Pred pred)
    {
        startPage();
        List<Pred> list = predService.selectPredList(pred);
        return getDataTable(list);
    }

    /**
     * 导出水质预测结果数据列表
     */
    @PreAuthorize("@ss.hasPermi('pred:pred:export')")
    @Log(title = "水质预测结果数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Pred pred)
    {
        List<Pred> list = predService.selectPredList(pred);
        ExcelUtil<Pred> util = new ExcelUtil<Pred>(Pred.class);
        util.exportExcel(response, list, "水质预测结果数据数据");
    }

    /**
     * 获取水质预测结果数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('pred:pred:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(predService.selectPredById(id));
    }

    /**
     * 新增水质预测结果数据
     */
    @PreAuthorize("@ss.hasPermi('pred:pred:add')")
    @Log(title = "水质预测结果数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Pred pred)
    {
        return toAjax(predService.insertPred(pred));
    }

    /**
     * 修改水质预测结果数据
     */
    @PreAuthorize("@ss.hasPermi('pred:pred:edit')")
    @Log(title = "水质预测结果数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Pred pred)
    {
        return toAjax(predService.updatePred(pred));
    }

    /**
     * 删除水质预测结果数据
     */
    @PreAuthorize("@ss.hasPermi('pred:pred:remove')")
    @Log(title = "水质预测结果数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(predService.deletePredByIds(ids));
    }
}
